package com.zj.ssm.service.impl;

import com.zj.ssm.mapper.NewsBsscMapper;
import com.zj.ssm.pojo.domain.News;
import com.zj.ssm.pojo.domain.query.NewsBsscQuery;
import com.zj.ssm.result.AjaxResult;
import com.zj.ssm.service.NewsBsscService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @author wxr
 * @version 1.0
 * @date 2022/1/17 14:09
 */
@Service
public class NewsBsscServiceImpl implements NewsBsscService {

    @Autowired
    private NewsBsscMapper newsBsscMapper;

    @Override
    public AjaxResult NewsBsscQuery(NewsBsscQuery query) {
        List<News> news = newsBsscMapper.queryNews(query);
        Long aLong = newsBsscMapper.queryNewsTotal(query);
        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("currentData",news);
        objectObjectHashMap.put("totalCount",aLong);



        return AjaxResult.success(objectObjectHashMap);
    }

    @Override
    public AjaxResult deleteNews(Integer id) {
        int i = newsBsscMapper.deleteNews(id);
        if (i<0){
            return AjaxResult.fail();
        }
        return AjaxResult.success();
    }

    @Override
    public AjaxResult getZhi(Integer id) {
        int i = newsBsscMapper.getZhi(id);
        if (i<0){
            return AjaxResult.fail();
        }
        return AjaxResult.success();
    }

    @Override
    public AjaxResult getXia(Integer id) {
        int i = newsBsscMapper.getXia(id);
        if (i<0){
            return AjaxResult.fail();
        }
        return AjaxResult.success();
    }

    @Override
    public AjaxResult getShang(Integer id) {
        int i = newsBsscMapper.getShang(id);
        if (i<0){
            return AjaxResult.fail();
        }
        return AjaxResult.success();
    }
}
